home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / C++ AppleLink Messages / CPlus.Dev$ 6⁄29⁄90 / 0146-Re walking the inher-Jun90 < prev    next >
Encoding:
Text File  |  1990-06-29  |  1.6 KB  |  37 lines  |  [TEXT/GEOL]

  1. Item    6672672                         26-June-90        10:19PDT
  2.  
  3. From:   D2605                           Xanadu Operating,Marc Stiegler,PRT
  4.  
  5. To:     MM.XOBJ                         MacroMind, Haim Zamir,PRT
  6.  
  7. cc:     CPLUS.DEV$                      C++ Interest List--Developers
  8.  
  9. Sub:    Re: walking the inheritance…
  10.  
  11. Haim,
  12.     We (at Xanadu) have written a set of simple macros which we use when
  13. defining new classes.  These macros statically create a "Category" object for
  14. each class we define.  (We didn't use the obvious "Class" because it's
  15. overloaded enough for us...)  We then define (as part of the macro) a
  16. getCategory method in each class, which returns a pointer to the statically
  17. defined category object.  The category object maintains the name of the class
  18. and the superclass.  This allows us to do dynamic type checking and other nifty
  19. stuff requiring dynamic type information.  The classes aren't difficult to
  20. write, if you need more info, write.
  21.     For the dynamic addition of methods, may I make a recommendation?
  22.  
  23. don't.
  24.  
  25.     A simple way to get the effect of adding dynamic code is to define a class
  26. that has a simple protocol - like "value".  Then, in a class where you want to
  27. add a function at runtime, instead add a member reference to one of these new
  28. classes.  When you would invoke the function, instead invode the value member
  29. function of the new class (you can overload with different numbers of
  30. parameters if necessary).  You will, of course, have to do some casting, but
  31. this is much cleaner and is portable.
  32.  
  33. --Hugh Hoover
  34.   Xanadu Operating Company, D2605
  35.  
  36.  
  37.